
module.exports = function(sequelize, DataTypes) {
    var Hospital = sequelize.define('hospital', {
        id: {
            type: DataTypes.INTEGER,
            allowNull: false,
            unique: true,
            primaryKey: true,
            autoIncrement: true
        },
        name: {
            type: DataTypes.STRING
        },
        level: {
            type: DataTypes.ENUM,
            values: [1, 2, 3, 4, 5, 6, 7, 8, 9]
        },
        area_id: {
            type: DataTypes.INTEGER,
            allowNull: false
        },
        address: {
            type: DataTypes.STRING
        },
        information: {
            type: DataTypes.TEXT('long')
        },
        telephoneNumber: {
            type: DataTypes.STRING
        }
    }, {
        underscore: true,
        'timestamps': false,
        'createdAt': false,
        'updatedAt': false
    }, {
        classMethods: {
            associate: function(models) {
                Hospital.belongsTo(models.Area, {
                    onDelete: "CASCADE",
                    onUpdate: "CASCADE",
                    foreignKey: {
                        allowNull: false
                    }
                });
                Hospital.hasMany(models.Doctor);
                Hospital.hasMany(models.Payment);
            }
        }
    });
    return Hospital;
};